﻿@using Models;

@{
    ViewBag.Title = "AllImages";
    var userImages = ViewBag.userImagesList as List<UserImage>;
    var newsImages = ViewBag.imagesInNewsList as List<ImageInNews>;
}
<a href="/admin/index" ><img src="/Content/images/back.png" /></a>
@Html.Partial("_openDialog")
<h2>AllImages</h2>

<table id="table_admin">
    <tr>
        <td>
            ID
        </td>
        <td>
            Name
        </td>
        <td>
            News ID
        </td>
        <td>
            Image
        </td>
        <td>
            Action buttons
        </td>
    </tr>
    @if (newsImages != null)
    {
        foreach (ImageInNews image in newsImages)
        {
            <tr>
                <td>
                    @image.Id
                </td>
                <td>
                    @image.Name
                </td>
                <td>
                    @image.NewsId
                </td>
                <td>
                    <a href="@image.Url" target="_blank"><img src="@image.Url" id="image_in_news"/></a>
                </td>
                <td>
                    <a href="/Admin/DeleteNewsImage/@image.Id" onmousedown=" return openDialog('@image.Id','/Admin/DeleteNewsImage');"><img src="/content/images/Delete.png" alt="Delete" /></a>
                </td>
            </tr>
        }
        if (userImages != null)
        {
            foreach (UserImage image in userImages)
            {
                <tr>
                    <td>
                        @image.Id
                    </td>
                    <td>
                        @image.Name
                    </td>
                    <td>
                        @image.UserId
                    </td>
                    <td>
                        <a href="@image.Url" target="_blank"><img src="@image.Url" id="image_in_news"/></a>
                    </td>
                    <td>
                        <a href="/Admin/DeleteUserImage/@image.Id" onmousedown="  return openDialog('@image.Id','/Admin/DeleteUserImage');"><img src="/content/images/Delete.png" alt="Delete" /></a>
                    </td>
                </tr>
            }
        }
    }
</table>